<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="myButton">点击我</button>
    <button onclick="handleClick()">点handleClick击</button>
    <script src="mitt.js" type="text/javascript"> </script>
    <script>
        const emitter = new Emitter();
        function handleClick() {
            console.log('触发');
            emitter.emit('myEvent', { key: 'value' });
           
        }
        emitter.on('myEvent', (data) => {
            console.log(data,'on 接受事件');
        });
        document.getElementById('myButton').addEventListener('click', handleClick);
    </script>

</body>

</html